// D3DDeviceDrvPrivate.h
//

#include "EnginePrivate.h"

#include <d3d11.h>
#include <d3dx11.h>
#include <d3dcompiler.h>

#include "D3DDeviceDrvTexture2D.h"
#include "D3DDeviceDrvEffect.h"

#include "common.hlsl"

//
// D3DDeviceDrv
//
class D3DDeviceDrv : public FGraphicsDevice {
public:
									D3DDeviceDrv() {
										g_driverType = D3D_DRIVER_TYPE_NULL;
										g_featureLevel = D3D_FEATURE_LEVEL_11_0;
									}
	virtual void					Init( FWindow *window );

	virtual void					SetViewport( int width, int height, float mindepth, float maxdepth, float topLeftX, float topLeftY );

	virtual void					Clear( void );

	virtual void					Present( void );

	virtual FTexture				*LoadImage( FString path );

	virtual FEffect					*LoadEffect( FString path );


	ID3D11Device* 					Device() { return g_pd3dDevice; }
private:
	void							CreateDepthStencilView( FWindow *window );
private:
	D3D_DRIVER_TYPE                 g_driverType;
	D3D_FEATURE_LEVEL               g_featureLevel;
	ID3D11Device*                   g_pd3dDevice;
	ID3D11DeviceContext*            g_pImmediateContext;
	IDXGISwapChain*                 g_pSwapChain;
	ID3D11RenderTargetView*         g_pRenderTargetView;
	ID3D11DepthStencilView*         g_pDepthStencilView;

	D3DTexture2D					*depthStencilTex2D;
};

extern D3DDeviceDrv d3dDevice;